<template>
    <div class="blogglobal">
        <div class="leftcontent">
            <div v-for="item in list" class="blogItem" @click="jump(item)">
                <div class="blog_title">{{item.title}}</div>
                <!-- <div class="blog_content" v-html="item.content">


                </div> -->
                <div class="blog-footer">
                    <div>{{item.createTime}}</div>
                    <div>作者: <span> {{item.name}}</span></div>
                    <div>所属分类: <span>{{item.typename}}</span></div>
                </div>
            </div>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page.sync="page" background :page-size="size" layout="total, prev, pager, next" :total="total">
            </el-pagination>
        </div>
        <div class="rightmodule">
            <div class="sub_title">分类专栏</div>
            <div class="typelist" v-for="item in typelist">
                <div class="typelogo">
                    <img :src="item.img" alt="">
                </div>
                <div class="typetitle">{{item.typename}}</div>

            </div>
        </div>


    </div>
</template>
<script>
import service from '@/request';

export default {
    data() {
        return {
            page: 1,
            total:0,
            size: 10,
            list:[],
            typelist:[]

        }
    },
    mounted() {
        this.getdata()
        this.gettype()
    },
    methods: {
        jump(item){
this.$router.push({
    path:"/detail",
    query:{
        item:JSON.stringify(item)
    }
})
        },
      async  gettype(){
            const res = await service.get(`/type/list`);
            console.log(res)
            this.typelist=res.data
           
        },
        handleCurrentChange(e) {
            this.page = e;
            this.getdata()
        },
        handleSizeChange(e) {
            this.size = e;
            this.getdata()
        },
        async getdata() {
            const res = await service.post(`/article/list?page=${this.page}&&size=${this.size}`);
            console.log(res)
            this.list=res.data.list
            this.total=res.data.total
        },
    }
}
</script>
<style scoped>
.typetitle {
    color: #1890ff;
}

.typelogo img {
    width: 100%;
    height: 100%;

}

.typelogo {
    width: 50px;
    height: 50px;
    background: #999aaa;
    margin-right: 10px;

}

.typelist {
    width: 100%;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.sub_title {
    font-size: 18px;
    color: #000;
    padding-bottom: 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
    border-bottom: 1px solid #ddd;
}

.blog-footer span {
    color: #1890ff;

}

.blog-footer div {
    margin-right: 10px;
}

.blog-footer {
    width: 100%;
    display: flex;
    font-size: 12px;
}

.blog_title {
    color: #1890ff;
    margin-bottom: 10px;
    font-size: 18px;
}

.blog_content {
    font-size: 12px;
    color: #999aaa;
    text-overflow: -o-ellipsis-lastline;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 24px;
}

.blogglobal {
    width: 100%;
    /* height: 100%; */
    padding: 20px;
    display: flex;
    justify-content: space-between;
    box-sizing: border-box;
}

.leftcontent {
    width: 74.5%;
    /* height: 100%; */
    background: #fff;
    padding: 15px;
    box-sizing: border-box;
    border-radius: 10px;
}

.rightmodule {
    width: 24.5%;
    /* height: 100%; */
    background: #fff;
    border-radius: 10px;
    padding: 10px;
    box-sizing: border-box;
}

.blogItem {
    width: 100%;
    height: auto;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 10px;
    padding-bottom: 10px;
    box-sizing: border-box;

}
</style>